
//文件流用于读取大文件(img json)

const fs = require('fs')
const zlib = require('zlib')

//可读流对象
const readStream = fs.createReadStream('data/data.json',{encoding:'utf8'})

//可写流对象
// const writeStream = fs.createWriteStream('data/data2.json',{encoding:'utf8'})

//可写流对象压缩
const writeStream = fs.createWriteStream('data/data3.json.gz',{encoding:'utf8'})

// readStream.pipe(writeStream) //管道输送 

//压缩输送
readStream
.pipe(zlib.createGzip())
.pipe(writeStream)